<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script type="text/javascript" src="./js/angular.min.js"></script>
<style type="text/css">
.red{color:red;}
</style>
</head>
<body>
<div ng-app="myApp" ng-controller="myAppController">

</div>
<script type="text/javascript">
// 通过 provide 可以自定义服务
var myApp = angular.module("myApp",[],function($provide){
	$provide.provider("customOne",function(){
		this.$get = function(){
			return {
				name : "张三"
			};
		};
	});
	$provide.provider("customTwo",function(){
		this.$get = function(){
			return {
				name : "李四"
			};
		};
	});
	// factory方法直接把一个函数当做 $provider 的 $get 方法 
	$provide.factory("customThr",function(){
		return {
			name : "王五"
		};
	});
	// service 服务
	$provide.service("customFour",function(){
		return ['red','orange'];
	});
});
myApp.controller("myAppController",function($scope,customOne,customTwo,customThr,customFour){
	console.log(customOne);
	console.log(customTwo);
	console.log(customThr);
	console.log(customFour);
});
</script>
</body>
</html>